package com.asp.alumnisystem.fragment;

import com.asp.alumnisystem.adapter.FriendListAdapter;
import com.asp.alumnisystem.base.IViewAdapter;
import com.asp.alumnisystem.model.UserModel;
import com.asp.alumnisystem.presenter.FriendPresenter;
import com.asp.alumnisystem.presenter.OptFriendPresenter;

/**
 * 首页好友页面
 */
public class FriendFragment extends AspBaseFragment<UserModel> implements FriendListAdapter.DelFriendListener {

    private OptFriendPresenter optPresenter;


    @Override
    protected void initView() {
        setTitleStr("好友");
        adapter = new FriendListAdapter(recyclerView, this);
        presenter = new FriendPresenter(this);
        managerPresenter(presenter);
        recyclerView.setAdapter(adapter);
        onRefresh(null);
    }

    @Override
    protected void destroy() {

    }


    @Override
    public void delFriendClick(int position, UserModel model) {
        initOptPresenter();
        optPresenter.delFriend(model.getUserId());
        adapter.delItem(position);
    }

    private void initOptPresenter(){
        if (optPresenter == null){
            optPresenter = new OptFriendPresenter(new IViewAdapter() {});
        }
    }
}
